//
//  KDMenuView.m
//  LaiKeDaoClient
//
//  Created by dongkedi的iMac on 15/11/11.
//  Copyright © 2015年 LKD. All rights reserved.
//

#import "KDMenuView.h"

@implementation KDMenuView

-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        
        UIButton *btn3 = [self getButton];
        [btn3 setFrame:self.frame];
        [btn3 setTag:103];
        [btn3 setBackgroundColor:[UIColor blackColor]];
        [btn3 setAlpha:0.3];
        [self addSubview:btn3];
        
        [self createUI];
    }
    return self;
}

- (void)createUI
{
    UIImageView     *backImageView = [[UIImageView alloc] initWithFrame:(CGRect){WIDTH(self)-100,0,85,59}];
    [backImageView setImage:[UIImage imageNamed:@"set_menu@2X.png"]];
    [backImageView setUserInteractionEnabled:YES];
    [self addSubview:backImageView];
    
    UIButton *btn1 = [self getButton];
    [btn1 setFrame:(CGRect){0,8,WIDTH(backImageView),24}];
    [btn1 setTitle:@"编辑标签" forState:UIControlStateNormal];
    [btn1 setTag:101];
    [backImageView addSubview:btn1];
    
    UIView  *line = [[UIView alloc] initWithFrame:(CGRect){5,Y(btn1)+HEIGHT(btn1),WIDTH(backImageView)-10,1}];
    [line setBackgroundColor:[UIColor whiteColor]];
    [backImageView addSubview:line];
    
    UIButton *btn2 = [self getButton];
    [btn2 setFrame:(CGRect){0,Y(btn1)+HEIGHT(btn1)+1,WIDTH(backImageView),24}];
    [btn2 setTitle:@"加入黑名单" forState:UIControlStateNormal];
    [btn2 setTag:102];
    [backImageView addSubview:btn2];
}

- (void)buttonClick:(UIButton *)btn
{
    if (btn.tag == 101) {
        //
    }else if (btn.tag == 102){
        
    }else if (btn.tag == 103){
        
    }
    if ([self.menuDelegate respondsToSelector:@selector(chooseButton:)]) {
        [self.menuDelegate chooseButton:btn.tag];
    }
}

- (UIButton *)getButton
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundColor:[UIColor clearColor]];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [button.titleLabel setFont:[UIFont systemFontOfSize:12]];
    return button;
}


@end
